Fix Icalendar export with ISO dates
authorEli Zaretskii <eliz@gnu.org>
Sat, 13 Apr 2024 07:52:55 +0000 (10:52 +0300)
committerEli Zaretskii <eliz@gnu.org>
Sat, 13 Apr 2024 07:52:55 +0000 (10:52 +0300)
* lisp/calendar/icalendar.el (icalendar--datestring-to-isodate):
Accept dashes in ISO-style numeric dates.  Patch by Erwan Hingant
<erwan.hingant@mailo.com>. (Bug#69894)

* test/lisp/calendar/icalendar-tests.el
(icalendar--datestring-to-isodate): Add a test for dashes in
ISO-style numeric dates.

lisp/calendar/icalendar.el
test/lisp/calendar/icalendar-tests.el

index d7e62e1baf39b8ae572b807a1b341ad798c61843..95b0496907576dde5ca80ce796e34409ac9b1b9c 100644 (file)
@@ -895,8 +895,8 @@ it uses the current calendar date style."
     (save-match-data
       (cond ( ;; iso-style numeric date
              (string-match (concat "\\s-*"
-                                   "\\([0-9]\\{4\\}\\)[ \t/]\\s-*"
-                                   "0?\\([1-9][0-9]?\\)[ \t/]\\s-*"
+                                   "\\([0-9]\\{4\\}\\)[ \t/-]\\s-*"
+                                   "0?\\([1-9][0-9]?\\)[ \t/-]\\s-*"
                                    "0?\\([1-9][0-9]?\\)")
                            datestring)
              (setq year (read (substring datestring (match-beginning 1)
index 39ad735a7897f8c2953183415ee50614906e14a6..32c06cbc533bc76b894c325826e1fe8de3c2a54c 100644 (file)
@@ -368,6 +368,9 @@ END:VTIMEZONE
                     (icalendar--datestring-to-isodate "2008 05 31")))
     (should (string= "20080602"
                     (icalendar--datestring-to-isodate "2008 05 31" 2)))
+    ;; Bug#69894
+    (should (string= "20240319"
+                    (icalendar--datestring-to-isodate "2024-03-19")))
 
     ;; numeric european
     (setq calendar-date-style 'european)